<template>
  <div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>基本信息</h4>
        <el-form label-width="180px">
          <el-row>
              <el-form-item label="分公司">
                <span>{{detailData.branchName}}</span>
              </el-form-item>
              <el-form-item label="所属部门">
                <span>{{detailData.departName}}</span>
              </el-form-item>
              <el-form-item label="客资类型">
                <span>{{detailData.customerName}}</span>
              </el-form-item>
              <!--<el-form-item label="所属仓库">-->
                <!--<span>{{detailData.limitStoreName}}</span>-->
              <!--</el-form-item>-->
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>基本信息</h4>
        <el-form label-width="180px">
          <el-row>
              <el-form-item label="活动名称">
                <span>{{detailData.promotion_name}}</span>
              </el-form-item>
              <el-form-item label="副标题">
                <span>{{detailData.sub_promotion_name}}</span>
              </el-form-item>
              <el-form-item label="满">
                <span>{{detailData.limit_full_money}}</span> 元
              </el-form-item>
              <el-form-item label="活动起止时间">
                <span>{{detailData.start_time}}</span> -
                <span>{{detailData.end_time}}</span>
              </el-form-item>
              <el-form-item label="用户参与次数">
                <span>{{detailData.limit_attend_count}}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>加价购商品</h4>
        <el-table :data="detailData.vice_product" border width="100%">
          <el-table-column prop="productid" label="商品ID" align="center" width="90"></el-table-column>
          <el-table-column prop="name" label="商品名称" align="center"></el-table-column>
          <el-table-column prop="saleunit" label="单位" align="center" width="100"></el-table-column>
          <el-table-column prop="salenorm" label="规格" align="center" width="100"></el-table-column>
          <el-table-column prop="saleprice" label="系统售价" align="center" width="100"></el-table-column>
          <el-table-column prop="cgprice" label="最后一次采购价" align="center" width="100"></el-table-column>
          <el-table-column prop="promotionprice" label="换购单价" align="center" width="100"></el-table-column>
          <el-table-column prop="num" label="数量" align="center" width="100"></el-table-column>
          <el-table-column prop="totalnum" label="总数量" align="center" width="100"></el-table-column>
          <el-table-column prop="cxName" label="促销费用" align="center" width="120"></el-table-column>
          <el-table-column prop="providerholdprice" label="供货商承担金额" align="center" width="170"></el-table-column>
        </el-table>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px">
      <div class="form-item">
        <h4>商品信息</h4>
        <el-table :data="detailData.main_product" border width="100%">
          <el-table-column prop="productid" label="商品ID" align="center" width="90"></el-table-column>
          <el-table-column prop="name" label="商品名称" align="center"></el-table-column>
          <el-table-column prop="saleunit" label="单位" align="center" width="100"></el-table-column>
          <el-table-column prop="salenorm" label="规格" align="center" width="100"></el-table-column>
          <el-table-column prop="saleprice" label="系统售价" align="center" width="100"></el-table-column>
          <el-table-column
            label="操作"
            align="center"
            width="100" >
            <template scope="scope">
              <el-button v-if="status === 5 || status === 6" @click="offline(scope.$index, scope.row, $event)" size="small">下线</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="detail-info" style="margin-top: 43px;margin-bottom:80px">
      <div class="form-item">
        <h4>审核信息</h4>
        <el-table :data="detailData.checkInfo" border>
          <el-table-column prop="auditor" label="审核人名称" align="center"></el-table-column>
          <el-table-column prop="content" label="任务内容" align="center"></el-table-column>
          <el-table-column prop="resultName" label="审核结果" align="center"></el-table-column>
          <el-table-column prop="opinion" label="审核意见" align="center"></el-table-column>
          <el-table-column prop="auditTime" label="审核时间" align="center"></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
<script>
  import { activity } from '../../../../../config/proxy.js'
  export default {
    data () {
      return {
        detailData: [],
        status: ''
      }
    },
    methods: {
      searchDetail (id) {
        activity.sphd.detail({id: id}, (res) => {
          console.log(res, '加价购详情')
          if (res.message === 'ok') {
//            res.content.limit_full_reduction = JSON.parse(res.content.limit_full_reduction)
            this.detailData = res.content
          } else {
            this.message('查看详情失败', 'error')
          }
        })
      },
      timeDeltSecond (d) { // 时间去秒
        if (d) {
          return d.split(' ')[0]
        }
      },
      message (text, type) { // 消息提示
        this.$message({
          showClose: true,
          message: text,
          type: type
        })
      },
      offline (index, row, event) {
        activity.sphd.myj.manjian.offline({}, (res) => {
          if (res.message === 'ok') {
          } else {
          }
        })
      } // 商品下线
    },
    created () {
      this.status = this.$store.state.tab.uid.status
      this.searchDetail(this.$store.state.tab.uid.id)
    }
  }
</script>

